package com.shujia.mr.hw.home2;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * 自定义分区类需要继承Partitioner，其泛型为Map端输出的Key和Value
 */
public class Home2Partition extends Partitioner<Text, Text> {

    @Override
    public int getPartition(Text key, Text value, int numPartitions) {
        int totalScore = Integer.parseInt(value.toString());
        if (totalScore > 450) {
            return 0;
        } else if (totalScore > 350) {
            return 1;
        }else {
            return 2;
        }
    }
}
